<?php
declare (strict_types = 1);

namespace app\api\model\v1;

use think\Model;

/**
 * @mixin \think\Model
 */
class WxUser extends AppModel
{
    //


    /**
     * Notes:
     * User: liuhailong
     * DateTime: 2022/3/29 14:58
     * @param $mobile
     * @return WxUser|array|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * 检查手机号是否存在
     */
    public static function checkMobile($mobile){
        $res = self::where('mobile',$mobile)->find();
        return $res;
    }

    /**
     * Notes:
     * User: liuhailong
     * DateTime: 2022/3/29 15:02
     * @param $data
     * @return int|string
     * 新增用户
     */
    public static function saveWxUser($data){
        $id = self::create($data)->id;
        return $id;
    }

    /**
     * Notes:
     * User: liuhailong
     * DateTime: 2022/3/29 15:09
     * @param $id
     * @return WxUser|array|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     * 根据id查找用户
     */
    public static function getWxUserById($id){
        $res = self::find($id);
        return $res;
    }
}
